using System;
using System.Collections.Generic;
using System.Text;
using IWMAG.Core.Hitboxes;
using Microsoft.Xna.Framework;
using System.Reflection;
using IWMAG.Core.Objects;

namespace IWMAG.Engine {
    public partial class GameEngine {
        protected void LinkApi() {
            foreach (MethodInfo method in GetType().GetMethods(BindingFlags.NonPublic | BindingFlags.Instance)) {
                if (method.Name.StartsWith("ScriptApi_")) {
                    string name = method.Name.Substring(10).ToLower();
                    Script.Externalize(name, method.Name, this);
                }
            }
        }

        protected float ScriptApi_Version() {
            return 1.0f;
        }

        protected GameObject ScriptApi_Spawn_Actor(/*ActorModel something?*/) {
            return null;
        }

        protected void ScriptApi_Register_Area(Rectangle rect, string ev, string function) {
            // (a) => { Script.Call(function); };
        }

        protected void ScriptApi_Show_Console(bool on) {
            showConsole = on;
        }

        protected void ScriptApi_Declare_Ground(Rectangle rect) {
            CurrentLevel.Solids.Add(new RectHitbox(rect));
        }

        protected void ScriptApi_Hook(string ev, string function) {
        }

        protected void ScriptApi_Hook_Actor(GameObject o, string ev, string function) {
        }

        Random randomSeed;
        protected int ScriptApi_Random(int low, int high) {
            if (randomSeed == null) {
                randomSeed = new Random();
            }

            return randomSeed.Next(low, high);
        }
    }
}
